import dayjs from "dayjs";


const rainTypes = [
    {
        'code': 'STFC/medium/SEVP_NMC_STFC_SFER_ER6T06_ACHN_L88_P9_',
        'val': 6, 'data':
            [{ val: 6, code: "000000606",code1:'STFC/medium/SEVP_NMC_STFC_SFER_ER6T06_ACHN_L88_P9_' },
            { val: 12, code: '000001206',code1:'STFC/medium/SEVP_NMC_STFC_SFER_ER6T12_ACHN_L88_P9_'  },
            { val: 18, code: '000001806' ,code1:'STFC/medium/SEVP_NMC_STFC_SFER_ER6T18_ACHN_L88_P9_' },
            { val: 24, code: '000002406' ,code1:'STFC/medium/SEVP_NMC_STFC_SFER_ER6T24_ACHN_L88_P9_' }]
    },
    {
        'code': 'STFC/medium/SEVP_NMC_STFC_SFER_ER24_ACHN_L88_P9_',
        'val': 24, 'data':
            [{ val: 24, code: '010002400' },
            { val: 48, code: '010004800' },
            { val: 72, code: '010007200' },
            { val: 96, code: '000009600' },
            { val: 120, code: '000012000' },
            { val: 144, code: '000014400' },
            { val: 168, code: '000016800' }]
    }
];


const getImgslist = () => {
    var dayObj = dayjs();
    var list = [];
    // for (let i = 4; i >= 1; i--) {
    //     //过去4天
    //     let obj2 = dayObj.subtract(i, 'day');
    //     let url = 'http://image.nmc.cn/product' + obj2.format('/YYYY/MM/DD/') + rainTypes[1]['code'] + obj2.format('YYYYMMDD') + rainTypes[1]['data'][0]['code']+'.JPG';
    //     list.push({
    //         'url':url,
    //         'time':obj2.format('YYYY-MM-DD')
    //     });
    // }
    for(let i of rainTypes[0]['data']){
        let url = 'http://image.nmc.cn/product' +dayObj.format('/YYYY/MM/DD/') + i['code1'] + dayObj.format('YYYYMMDD') + i['code']+'.JPG';
        list.push({
            'url':url,
            'time':dayObj.format('YYYY-MM-DD')+ ' '+i.val+"时"
        });
    }
    for(let i of rainTypes[1]['data']){
        if(i.val==24){
            continue;
        }
        let url = 'http://image.nmc.cn/product' +dayObj.format('/YYYY/MM/DD/') +rainTypes[1]['code'] + dayObj.format('YYYYMMDD') + i['code']+'.jpg';
        list.push({
            'url':url,
            'time':dayObj.format('YYYY-MM-DD')+ ' '+i.val+"时"
        });
    }
    return list;
}

export {getImgslist}